﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2017._01._19.Stack
{
    class Stack
    {
        private int count;
        private object znachenie;
        private ArrayList kucha = new ArrayList();
        


        public object Pop()
        {
            count--;
            if (count >= 0)
            {
                znachenie = kucha[count];
                kucha.RemoveAt(count);
            }
            else
            {
                Console.WriteLine("Похоже, это конец");
                znachenie = null;
            }
            return znachenie;
        }

        public void Clear()
        {
            kucha.Clear();
            count = 0;
        }

        public void Push(object znachenie)
        {
            kucha.Add(znachenie);
            count++;
        }

    }
}
